<?php

abstract class BaseUI {

	private $title;

	private $css;

	private $javascript;

	protected $display;

	protected abstract function constructHeaderTag();

	protected abstract function getHeader();

	protected abstract function getContent();

	protected abstract function getFooter();

	protected function setDisplay($key, $data) {
		$this->display[$key] = $data;
	}

	protected function constructTemplate() {
		$this->constructHeaderTag();
		$this->getHeader();
		$this->getContent();
		$this->getFooter();
	}

	protected function template($page) {
		$page = VIEW . '/' . $page . EXT;

		require_once $page;
	}

	protected function setCss($css) {
		$this->css[] = $css;
	}

	protected function setJavascript($js) {
		$this->javascript[] = $js;
	}

	protected function setTitle($title) {
		$this->title = $title;
	}

	protected function getCss() {
		return $this->addCss($this->css);
	}

	protected function getJavascript() {
		return $this->addJs($this->javascript);
	}

	protected function getTitle() {
		return $this->title;
	}

	protected function addCss($css) {
		$cssFiles = '';

		if (is_array($css)) {
			foreach ($css AS $file) {
				$cssFiles .= '<link rel="stylesheet" type="text/css" href="' . TemplateHelper::getCssUrl() . $file . '.css " />' . "\n";
			}
		}

		return $cssFiles;
	}

	protected function addJs($js) {
		$jsFiles = '';

		if (is_array($js)) {
			foreach ($js AS $file) {
				$jsFiles .= '<script src="' . TemplateHelper::getJsUrl() . $file .'.js"></script>' . "\n";
			}
		}

		return $jsFiles;
	}
}